/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIArquivo.java
 *
 * Created on 10/12/2010, 15:10:28
 */

package ifpb.pod.cliente.visao;

import java.io.File;
import java.io.FileInputStream;
import javax.swing.JOptionPane;

/**
 *
 * @author Diogenes
 */
public class GUIArquivo extends javax.swing.JFrame {

    /** Creates new form GUIArquivo */
    public GUIArquivo() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        chose = new javax.swing.JFileChooser();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        chose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                choseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(chose, javax.swing.GroupLayout.DEFAULT_SIZE, 624, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(chose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void choseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_choseActionPerformed
//       this.chose.getCurrentDirectory();
       File f = this.chose.getSelectedFile();
//        try {
//            FileInputStream is = new FileInputStream(f);
//            BufferedInputStream bis = new BufferedInputStream(is);
//
//        } catch (FileNotFoundException ex) {
//            Logger.getLogger(GUIArquivo.class.getName()).log(Level.SEVERE, null, ex);
//        }
//       ByteArrayOutputStream out = new ByteArrayOutputStream();

       FileInputStream arquivoFile = null;
        int tamanho = (int) f.length();
        byte[] buffer = new byte[tamanho];

        try {
            arquivoFile = new FileInputStream(f);
            arquivoFile.read(buffer, 0, tamanho);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Erro");
            ex.printStackTrace();
        }

        System.out.println(f);
    }//GEN-LAST:event_choseActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GUIArquivo().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser chose;
    // End of variables declaration//GEN-END:variables

}
